package utl.mofen.jsonStreamHandler;

import java.util.Hashtable;

public class HandlerSession {
	Hashtable<String, Object> store = new Hashtable<String, Object>();
	static Hashtable<String, HandlerSession> globalSession = new Hashtable<String, HandlerSession>();
	
	public static HandlerSession getHandlerSession(String sessionID)
	{
		HandlerSession ret = globalSession.get(sessionID);
		if (ret==null)
		{
			ret = new HandlerSession();
			globalSession.put(sessionID, ret);
		}
		return ret;
	}
	
	public void setSession(String key, Object value)
	{
		//Hashtable sto = new Hashtable();		
		store.put(key, value);
	}
	
	public Object getSession(String key)
	{		
		return store.get(key);
	}
	
	public String getAsString(String key)
	{
		Object obj = getSession(key);
		if (obj==null)
		{
			return null;
		}else
		{			
			return (String)obj;
		}
	}
	
	public Boolean getAsBoolean(String key)
	{
		Object obj = getSession(key);
		if (obj==null)
		{
			return false;
		}else
		{			
			return (Boolean)obj;
		}
	}
}
